#include "geometryShapeConstruction.h"


geometryShapeConstruction::geometryShapeConstruction()
{
AICaption=wxT("geometryShapeConstruction ") ;
}

geometryShapeConstruction::~geometryShapeConstruction()
{
    //dtor
}
void *geometryShapeConstruction::Entry()
{
BFrame->AIActionWatchTextBox->AppendText(TERM+wxT(" 熵形开始分析..")+wxNow()+wxT("\n"));
//得到上一期的数字
wxString SQL=wxT(" select * from _DBHISTORY  where term<'")+TERM+wxT("' order by term desc  limit 0,1");
//::wxGetTextFromUser(wxEmptyString,wxEmptyString,SQL);
DoubleBall* db= new DoubleBall();
 db->query(SQL.char_str());
wxArrayString form;
wxString test;
wxString formTerm=wxString::FromAscii(db->records[db->ncol+0]);
for(int i=2;i<db->ncol-1;i++)
{
    test=test+wxString::Format(wxT("%02d"),atoi(db->records[db->ncol+i]))+wxT(",");
    form.Add(wxString::Format(wxT("%02d"),atoi(db->records[db->ncol+i])));
}
form.Sort(false);
BFrame->AIActionWatchTextBox->AppendText(formTerm +wxT(":")+arrary2string(form) +wxT(" 最大数:")+getMaxRedball(form)+wxT(" 最小数:")+getMinRedball(form)+wxT("\n"));
fakeHTable cont=findContinuum(form);
BFrame->AIActionWatchTextBox->AppendText(formTerm+wxT(" 得到连续数组合个数:")+wxString::Format(wxT("%02d"),cont.size())+wxT("\n"));
wxArrayString t1;
fakeHTable::iterator it;

for( it = cont.begin(); it != cont.end(); ++it )
  {
 t1= it->second;
 BFrame->AIActionWatchTextBox->AppendText(arrary2string(t1)+wxT("\n"));
  }
switchHashMap distance=getRedballDistance(form);
switchHashMap sum=getRedballSum(form);

BFrame->AIActionWatchTextBox->AppendText(hashmap2string(distance)+wxT("\n"));
BFrame->AIActionWatchTextBox->AppendText(hashmap2string(sum)+wxT("\n"));
BFrame->AIActionWatchTextBox->AppendText(wxT("重复数\n")+bothInclude(distance,sum)+wxT("\n"));

delete db;
}
//logic code in here
void geometryShapeConstruction::OnExit(){};

wxArrayString geometryShapeConstruction::tellMe(wxString term)
{
    TERM=term;
    wxArrayString result;
    Entry();
    return result;
}

wxString geometryShapeConstruction::getName()
{
  return wxT("geometryShapeConstruction:");
}

IMPLEMENT_DYNAMIC_CLASS(geometryShapeConstruction, AIBase);
